import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str;
        while (true) {
            System.out.println("请输入一个字符串");
            str = sc.next();
            boolean flag = checkStr(str);
            if (flag) {
                break;
            } else {
                System.out.println("当前字符串不符合规则,请重新你输入:");
                continue;
            }
        }
        StringBuilder sb = new StringBuilder();//字符串拼接
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);

           String s = changeLuoMa(c);
            sb.append(s);

        }
        System.out.println(sb);
    }
    public static String changeLuoMa(char number){

        String str=  switch(number){
            case '0' ->  "";
            case '1' -> "I";
            case '2' -> "II";
            case '3' ->  "III";
            case '4' -> "IV";
            case '5' -> "V";
            case '6' -> "VI";
            case '7' -> "VII";
            case '8' -> "VIII";
            case '9' -> "IX";
            default -> "";

        };
        return str;
    }
    public static boolean checkStr(String str){
        if(str.length()>=9){
            return false;
        }
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if(c<'0'||c>'9'){
                return false;
            }
        }
        return true;
    }
}